﻿using System;
using System.Windows.Forms;
using Sedge.Core.Globalization;
using Sedge.UI.Controller;
using Sedge.UI.ViewModel;

namespace Sedge.UI.View
{
	public partial class TrackingInfoView : UserControl, ITransferable
	{
		private readonly TrackingInfoViewModel _viewModel;

		public TrackingInfoView()
		{
			InitializeComponent();
		}

		public TrackingInfoView(TrackingInfoViewModel viewModel) : this()
		{
			_viewModel = viewModel;
			SetupWindow();
		}

		private void SetupWindow()
		{
			labelFeature.Text = Locale.Strings.TrackingInfoFeature;
			int colWidth = labelFeature.Right;

			labelStory.Text = Locale.Strings.TrackingInfoStory;
			colWidth = Math.Max(colWidth, labelStory.Right);

			labelIteration.Text = Locale.Strings.TrackingInfoIteration;
			colWidth = Math.Max(colWidth, labelIteration.Right);

			labelContact.Text = Locale.Strings.TrackingInfoContact;
			colWidth = Math.Max(colWidth, labelContact.Right);

			labelNotes.Text = Locale.Strings.TrackingInfoNotes;
			colWidth = Math.Max(colWidth, labelNotes.Right);

			textFeature.Left = colWidth;
			textStory.Left = colWidth;
			textIteration.Left = colWidth;
			textContact.Left = colWidth;
		}

		public void TransferData()
		{
			_viewModel.StoreData(textFeature.Text, textStory.Text, textIteration.Text, 
										textContact.Text, textNotes.Lines);
		}
	}
}
